# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>
#
_realname=contextlib2
pkgbase=mingw-w64-python3-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
pkgver=0.6.0
pkgrel=1
pkgdesc="contextlib2 is a backport of the standard library’s contextlib module to earlier Python versions (mingw-w64)"
arch=('any')
url="https://pypi.python.org/pypi/${_pypiname}"
license=('PSF')
depends=("${MINGW_PACKAGE_PREFIX}-python3")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools")
source=("https://pypi.io/packages/source/${_realname:0:1}/${_realname}/${_realname}-$pkgver.tar.gz")
sha512sums=('01901ac226c7fca40add00e95cedb2535a802e0114a53ae1315c6dfee20744dbafa7d9619986ad76345ad9b9aa3e364ac01d23f51b5eb70dd2febd5af1f1fc56')

prepare() {
  cd "${srcdir}"
  rm -rf python3-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python3-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
  export PBR_VERSION=$pkgver
}

build() {
  msg "Python 3 build for ${CARCH}"  
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python3 setup.py build
}

package() {
  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"
  install -Dm644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
}
